<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://unpkg.com/vue"></script>
</head>
<body>
<div id="demo">{{fullName}}</div>
<script>
//    <!--计算属性默认只有getter，不过在需要时你也可以提供一个setter-->
  var vm=new Vue({
      el:'#demo',
      data:{
          firstName:'Foo',
          lastName:'Bar',
      },
      computed:{
         fullName:{
             //getter
             get: function(){
                 return this.firstName+' '+this.lastName
         },
             //setter
             set:function(newValue){
                 var names=newValue.split('')
                 this.firstName=name[0]
                 this.lastName=names[names.length-1]
             }

         }
      }

  })

</script>
</body>
</html>